﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using Extensibility;
using EnvDTE;
using EnvDTE80;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using CoNatural.Data.VisualStudio.AddIn.Helpers;

namespace CoNatural.Data.VisualStudio.AddIn.Forms {
	public partial class NewCommandWizardForm : SelectedItemWizardForm {
		private Controls.NewCommandControl step0;

		public NewCommandWizardForm(SelectedItem selectedItem) : base(selectedItem) {
			InitializeComponent();

			this.Text = "New CoNatural Command - " + RootNamespace;

			step0 = new CoNatural.Data.VisualStudio.AddIn.Controls.NewCommandControl();

 			Initialize(
				new WizardStep(step0, true, false, "Step 1 of 2 - Enter Command Name.", null)
			);
		}

		protected override bool OnGoBack() {
			return base.OnGoBack();
		}

		protected override bool OnGoNext() {
			return false;
		}

		protected override bool OnFinish(BackgroundWorker worker) {
			if (string.IsNullOrEmpty(step0.CommandName))
				return false;

			var builder = new CommandBuilder(RootCollection, RootPath, RootNamespace);
			builder.CreateCommand(step0.CommandName);
			return true;
		}
	}
}
